package com.gonsin.base;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 翻页请求（搜索）
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GPageRequest {

    /**
     * 当前页
     */
    @NotNull(message = "请填写页码page")
    @ApiParam(value = "页面，从0开始", example="0")
    private int page;

    /**
     * 每页个数
     */
    @NotNull(message = "请填写每页个数page")
    @ApiParam(value = "每页个数", example="10")
    private int count;

    /**
     * 每页个数
     */
    @ApiParam("排序方向，+createTime表示按createTime递增排序，多个排序方式用逗号隔开，例如，+create_time,-name")
    private String sort;


    /**
     * 查询全部
     */
    public static GPageRequest all(){
        GPageRequest request = new GPageRequest();
        request.setPage(0);
        request.setCount(Integer.MAX_VALUE);
        request.setSort(null);
        return request;
    }


    /**
     * 查询一个
     */
    public static GPageRequest one(){
        GPageRequest request = new GPageRequest();
        request.setPage(0);
        request.setCount(1);
        request.setSort(null);
        return request;
    }

}

